import copy
class SettingConfig:
    _csvFilePath="readcsv.csv"#要批量生成的csv数据来源

    _buildType = 0 #如果csv中含有ValueType 那么这个值改变成1
    _buildTypePool=["string","url"]
    _buildFileType=".qml"#生成的文件类型    
    _buildFilePrefix="Plan_"#生成文件的前缀
    _buildBegin='''
import QtQuick 2.2
//资源
Item {
\t\t\t\tid: tpRoot;\n
'''
    _buildEnd='''
\n}\n
// fomate Tool build
// smy \n
    '''

    _defcsvInfo=["ValueType","ValueName","ValueDef","Note"]#变量类型 ，变量名，默认变量，注释,除了这些的都为其他模式变量
    _defValueTypeInfo=["headPath","bg","img","icon","gif","frame"]#类型头路径 ，背景图片，通用图片，图标，动图，帧动图
    
    @staticmethod
    def getModels(headerInfos):
        tpInfo=list()
        valuemodelArray=[]
        index=1
        for i in headerInfos:
            # if i == SettingConfig._defcsvInfo[2]:
            #     continue
            # el
            if i == SettingConfig._defcsvInfo[1]:
                valuemodelArray.append(index)
            elif i == SettingConfig._defcsvInfo[3]:
                valuemodelArray.append(index)
            elif i == SettingConfig._defcsvInfo[0]:
                valuemodelArray.append(index)
            else:
                tpInfo.append(i)
            pass
       
        print(tpInfo)
        return tpInfo;
        
    @staticmethod
    def buildFileName(moelName):
        return f'{SettingConfig._buildFilePrefix}{moelName}{SettingConfig._buildFileType}'
    
    @staticmethod
    def buildHeadInfo(type,typePath):
        return f'\t\t\t\tproperty string {SettingConfig.buildSourceHead( type)}\t:\t"{typePath}"\n'
    
    @staticmethod 
    def buildSourceHead(type):
        return f'resource_{type}'

    @staticmethod
    def buildProperty(valueName,value,valueNote,isType=False,valueType=""):
        if isType is False:
            return f'\t\t\t\tproperty {SettingConfig._buildTypePool[0]} {valueName}\t:\t"{value}"\t//{valueNote}\n'
        else:
            typestr=valueType
            if valueType != "":
                typestr=valueType+"+"
            return f'\t\t\t\tproperty {SettingConfig._buildTypePool[1]} {valueName}\t:\t{typestr}"{value}"\t//{valueNote}\n'
            pass
    pass